<template>
  <div class="login">
    <div class="loginIn">
      <div class="loginLeft">
        <img src="@/assets/image/loginLeft.png" alt="" >
      </div>
      <div class="loginForm">
        <div class="loginFormTitle">
          <h3 >{{appName}}</h3>
          <p>- 账号登录 -</p>
        </div>
        <div>
          <el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-position="right">
            <el-form-item class="form-item loginInput" prop="username" >
              <input class="input" v-model="loginForm.code" autocomplete="off" name="code"placeholder="登录" />
              <i class="iconfont icon-a-bianzu140"></i>
            </el-form-item>
            <el-form-item  prop="password" class="form-item">
              <input class="input" type="password" v-model="loginForm.password" autocomplete="off" name="passworld" placeholder="密码"/>
              <i class="iconfont icon-a-bianzu1391"></i>
            </el-form-item>
            <el-form-item class="form-item">
              <span  class="handleLogin"  @click="handleLogin()"> 登录 </span>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
    <div class="logo">
      <div>Copyright©2024 zhuiyv all rights reserved.Powered</div>
    </div>
  </div>
</template>
<script>
import {createMD5} from '../../utils/utils'
import {listActiveHosp} from "../../api/manager/user";
import pageUtils from '../../utils/page-title-utils'
export default {
  name: 'login',
  data () {
    return {
      loginForm: {
        code: '',
        password: '',
        hospId:'H32058200623'
      },
      appName: '',
      loginRules: {
        code: [{required: true, trigger: 'blur', message: '请输入用户名'}],
        password: [{required: true, trigger: 'blur', message: '请输入密码'}]
      },
      hospList:[],
      loading: false
    }
  },
  created () {
    this.appName =  pageUtils.title;
  },
  methods: {
    handleLogin () {
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.loading = true
          let pwd = createMD5(this.loginForm.password)
          let userForm = {
            'username': this.loginForm.code,
            'password': pwd,
            'hospId':this.loginForm.hospId
          }
          this.$store.dispatch('user/login', userForm).then(data => {
            this.loading = false;
            this.$store.dispatch('user/sysManage',false);
            this.$store.dispatch('user/initRouter');
            this.$router.push({path: '/'})
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss">
  @import "../../styles/mixin";

  $bg: #D8DDDE;
  $dark_gray: #e4e2e0;
  $dark_blue: #0e2244;
  $test: #5a5e44;
  $test1: #5a5e44;
  .login{
    width: 100%;
    height: 100%;
    /*background: url(../../assets/img/login.png)no-repeat;*/
    /*background: url(../../assets/img/loginbg.jpg)no-repeat;*/
    /*background-size:100% 100%;*/
    background: linear-gradient(1deg, #11448C 0%, #000000 100%);
    display: flex;
    align-items: center;
  }
  .title{
    font-size: 28px;
    font-weight: bold;
    color: #FFFFFF;
    /*padding: 4% 0;*/
    padding: 52px 0 45px 0;
    text-align: center;
    letter-spacing: 1px;
  }
  .loginIn{
    display: flex;
    /*justify-content: center;*/
    align-content: center;
    height: 60%;
    width: 100%;
    justify-content: center;
  }
  .loginLeft{
    /*background: url(../../assets/img/loginbg.png)no-repeat;*/
    /*background-size:100% 100%;*/
    /*width: 35%;*/
    /*height: 69%;*/
    width: 342px;
    height: 373px;

  }
  .loginLeft>img{
    width: 100%;
    height: 100%;
  }
  .loginForm{
    /*height: 40%;*/
    /*width: 20.8%;*/

    width: 320px;
    height: 320px;
    /*background: #0B2D5D;*/
    /*border-radius: 12px;*/
    opacity: 0.8;
    /*border: 1px solid #11448C;*/
    box-sizing: border-box;
    margin-left: 200px;
  }
  .loginFormTitle{
    text-align: center;
    /*font-size: 20px;*/
    /*font-weight: bold;*/
    /*color: #E8F1FC;*/
    /*padding: 26px 0;*/
  }
  .loginFormTitle>h3{
    /*width: 207px;*/
    height: 40px;
    font-size: 28px;
    font-weight: 800;
    color: #FFFFFF;
    line-height: 40px;
    letter-spacing: 1px;
  }
  .loginFormTitle>p{
    height: 21px;
    font-size: 16px;
    font-weight: bold;
    color: #E8F1FC;
    line-height: 21px;
    margin: 11px 0 40px 0;
  }
  .form-item{
    /*width: 85%;*/
    width: 280px;
    margin: 0 auto;
    position: relative;
  }
  .form-item .iconfont{
    position: absolute;
    left: 12px;
    top: 1px;
    font-size: 18px;
    color: #A4C6F6;
  }
  .form-item .input{
    /*width: 340px;*/
    width: 100%;
    height: 36px;
    background: #0E3874;
    border-radius:8px;
    border: 1px solid #11448C;
    box-sizing: border-box;
    color: #fff !important;
    padding-left: 36px;
  }

  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #0E3874 inset !important;
    /* -webkit-text-fill-color: #fff; */
    -webkit-transition-delay: 99999s;
    -webkit-transition: color  99999s ease-out, background-color  99999s ease-out;
  }

  .form-item .el-input__inner{
    width: 100%;
    height: 36px;
    background: #0E3874;
    border-radius:8px;
    border: 1px solid #11448C;
    box-sizing: border-box;
    color: #fff  !important;
    padding-left: 36px;
  }

  .handleLogin{
    display: inline-block;
    width: 100%;
    height: 36px;
    background: #1D72EA;
    font-weight: bold;
    font-size: 16px;
    color: #fff;
    border: none;
    text-align: center;
    line-height:36px;
    /*margin-top: 30%;*/
    margin-top: 30px;
    cursor: pointer;
    border-radius: 8px;
  }
  .logo{
    position: absolute;
    bottom: 20px;
    left: 50%;
    text-align: center;
    margin-left: -200px;
  }
  .logoImg{
    margin-top: 60px;
    text-align: center;
  }
  .logo>div{
    color: #A4C6F6;
    padding-top: 40px;
  }
  .loginInput{
    margin-bottom: 12px !important;
  }
</style>
